package ocp

import (
    `io`
    `net/http`
)

// 开闭失效

type Person struct {
    Name, Email string
}

func BuildOutputOCPFail(w http.ResponseWriter, r *http.Request, format string, p Person) {

    var err error
    switch format {
    case "csv":
        err = outputCSV(w, p)
    case "json":
        err = outputJSON(w, p)

    }
    // output a server error and quit
    if err != nil {
        w.WriteHeader(http.StatusInternalServerError)
        return
    }
    w.WriteHeader(http.StatusOK)

}

// output the person as CSV and return error when failing to do so
func outputCSV(writer io.Writer, person Person) error {
    // TODO: implement
    return nil
}

// output the person as JSON and return error when failing to do so
func outputJSON(writer io.Writer, p Person) error {
    // todo:implement
    return nil

}
